<%--
  Created by IntelliJ IDEA.
  User: 14811
  Date: 2022-5-1
  Time: 10:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/common/common.jsp"%>
<!-- 头部 start -->
<header id="header">
    <div class="top_banner">
        <img src="<%=path%>/images/top_banner.jpg" width="1500px" hight="128px" alt="">
    </div>
    <div class="shortcut">
        <c:if test="${user==null}">
            <!-- 未登录状态  -->
            <div class="login_out">
                <a href="${pageContext.request.contextPath}/pageController/toLogin">登录</a>
                <a href="${pageContext.request.contextPath}/pageController/toRegister">注册</a>
            </div>
        </c:if>

        <!-- 登录状态  -->
        <c:if test="${user!=null}">
            <div class="login">
                <span>欢迎回来，${user.username}</span>
                <a href="${pageContext.request.contextPath}/pageController/toMyFavorite" class="collection">我的收藏</a>
                <a href="javascript:login_out();">退出</a>
            </div>
        </c:if>
    </div>
    <div class="header_wrap">
        <div class="topbar">
<%--            <div class="logo">--%>
<%--                <a href="/"><img src="<%=path%>/images/l" alt="" width="207px" hight="56px"></a>--%>
<%--            </div>--%>
            <div class="search">
                <input name="rname" type="text" placeholder="请输入路线名称" class="search_input" id="search_input" autocomplete="off">
                <a href="javascript:findRoute();" class="search-button">搜索</a>
            </div>
            <div class="hottel">
                <div class="hot_pic">
                    <img src="<%=path%>/images/hot_tel.jpg" alt="">
                </div>
                <div class="hot_tel">
                    <p class="hot_time">客服热线(9:00-6:00)</p>
                    <p class="hot_num">400-666-8888</p>
                </div>
            </div>
        </div>
    </div>
</header>
<!-- 头部 end -->
<!-- 首页导航 -->
<div class="navitem">
    <ul class="nav">
        <li class="nav-active"><a href="${pageContext.request.contextPath}/pageController/toIndex">首页</a></li>
        <c:forEach items="${categories}" var="c">
            <li><a href="${pageContext.request.contextPath}/pageController/toRouteList?cid=${c.cid}">${c.cname}</a></li>
        </c:forEach>
        <li><a href="${pageContext.request.contextPath}/pageController/toFavoriteRank">收藏排行榜</a></li>
    </ul>
</div>
<script type="text/javascript">
    function findRoute() {
        var input = $("#search_input").val()
        location.href="<%=path%>/indexController/toRouteListSearch?rname="+input;
    }
    function login_out() {
        //var uid = ${user.uid};
        $.ajax({
            url:"<%=path%>/indexController/loginOut",
            type:"post",
            dataType:"json",
            //data:{uid:uid},
            success:function (data) {
                if (data){
                    toastr.success("退出成功");
                    location.reload();
                }
            }

        })
    }
</script>
